{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f716c76d-8431-40d9-a9da-c5c1b7c7f875",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "打开浏览器访问页面2023-05-10 13:09\n",
      "浏览器启动并访问登录页成功，请速速扫码\n",
      "开始访问页面...  2023-05-10 13:10\n",
      "https://user.qzone.qq.com/3505457127/311\n",
      "https://user.qzone.qq.com/2747799504/311\n",
      "https://user.qzone.qq.com/2907195009/311\n",
      "https://user.qzone.qq.com/1939932512/311\n",
      "https://user.qzone.qq.com/3459746511/311\n",
      "https://user.qzone.qq.com/2827986956/311\n",
      "https://user.qzone.qq.com/2417453970/311\n",
      "https://user.qzone.qq.com/1634828782/311\n",
      "https://user.qzone.qq.com/1959387561/311\n",
      "https://user.qzone.qq.com/523740664/311\n",
      "页面访问完毕，lis生成，解析发送...\n",
      "1 >>> #枣子茶话会#如果是 <= 四川农业大学\n",
      "1 >>> #早安，川农# 我想 <= 四川农业大学\n",
      "1 >>> #晚安川农# 宁静的 <= 四川农业大学\n",
      "1 >>> #川农夜聊# 大家身 <= 四川农业大学\n",
      "0 >>> #川农微分享#【#四 <= 四川农业大学\n",
      "0 >>> #枣子茶话会# 画画 <= 四川农业大学\n",
      "0 >>> #早安，川农# 想感 <= 四川农业大学\n",
      "0 >>> #晚安川农# 如果生 <= 四川农业大学\n",
      "0 >>> #川农夜聊# 大家平 <= 四川农业大学\n",
      "0 >>> #枣子茶话会##中奖 <= 四川农业大学\n",
      "1 >>> #农场主听你说# <= 青春川农\n",
      "1 >>> #是投稿呀# <= 青春川农\n",
      "1 >>> #是活动呀# <= 青春川农\n",
      "1 >>> #农场主考考你# <= 青春川农\n",
      "1 >>> ＃早安川农＃ <= 青春川农\n",
      "1 >>> 【关于学生处学生教育 <= 青春川农\n",
      "1 >>> #川农奇葩说# <= 青春川农\n",
      "0 >>> #是活动呀# <= 青春川农\n",
      "0 >>> #是投稿呀# <= 青春川农\n",
      "0 >>> #一起去看# <= 青春川农\n",
      "0 >>> #虽然被封校了，但大 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>>  <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #征婚 <= 川农大的某盒子\n",
      "0 >>>  <= 川农大的某盒子\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "1 >>> 混合贴 <= 川农大绿帽墙\n",
      "1 >>>  <= 川农大绿帽墙\n",
      "0 >>>  <= 川农大绿帽墙\n",
      "0 >>> 今日趣事 <= 川农大绿帽墙\n",
      "0 >>> 混合贴 <= 川农大绿帽墙\n",
      "0 >>> 图一：信科 <= 川农大绿帽墙\n",
      "0 >>> 下午好 <= 川农大绿帽墙\n",
      "0 >>> 混合贴 <= 川农大绿帽墙\n",
      "0 >>> 图一：雅安医院 <= 川农大绿帽墙\n",
      "0 >>> 考研5月了，还没开始 <= 川农大绿帽墙\n",
      "1 >>>  <= 川农大新鲜事\n",
      "1 >>>  <= 川农大新鲜事\n",
      "1 >>>  <= 川农大新鲜事\n",
      "1 >>>  <= 川农大新鲜事\n",
      "1 >>>  <= 川农大新鲜事\n",
      "1 >>> 那么新鲜的花 <= 川农大新鲜事\n",
      "1 >>>  <= 川农大新鲜事\n",
      "1 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "1 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "1 >>> 川农也能打9+啦！ <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> 大家有在云养女鹅或者 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集🫰 <= 川农大表白墙（美好版）\n",
      "0 >>> 蛇哥！蛇哥你怎么上树 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集🤌 <= 川农大表白墙（美好版）\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>>  <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "-1 >>>  饿了么请大家来吃饭 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 1. [求助] 拜托 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 1. [征友] 图书 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 在川农大，我们谈场7 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [征友] 扩列 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [找人] 找一 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [征友] 找对 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [提问] 成都 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [找人] 捞人 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 1. [拼车] 在康 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>>  <= 纯路人茉日天\n",
      "1 >>>  <= 纯路人茉日天\n",
      "1 >>>  <= 纯路人茉日天\n",
      "1 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>> 【B限】《原友第一定 <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>> 二次元高手 <= 纯路人茉日天\n",
      "请求发送完毕\n",
      "打开浏览器访问页面2023-05-10 19:11\n",
      "浏览器启动并访问登录页成功，请速速扫码\n",
      "开始访问页面...  2023-05-10 19:12\n",
      "https://user.qzone.qq.com/3505457127/311\n",
      "https://user.qzone.qq.com/2747799504/311\n",
      "https://user.qzone.qq.com/2907195009/311\n",
      "https://user.qzone.qq.com/1939932512/311\n",
      "https://user.qzone.qq.com/3459746511/311\n",
      "https://user.qzone.qq.com/2827986956/311\n",
      "https://user.qzone.qq.com/2417453970/311\n",
      "https://user.qzone.qq.com/1634828782/311\n",
      "https://user.qzone.qq.com/1959387561/311\n",
      "https://user.qzone.qq.com/523740664/311\n",
      "页面访问完毕，lis生成，解析发送...\n",
      "1 >>> #川农微资讯# 【关 <= 四川农业大学\n",
      "1 >>> #枣子茶话会#距离2 <= 四川农业大学\n",
      "1 >>> #川农身边事# #9 <= 四川农业大学\n",
      "1 >>> #川农身边事# 【晒 <= 四川农业大学\n",
      "0 >>> #枣子茶话会#如果是 <= 四川农业大学\n",
      "0 >>> #早安，川农# 我想 <= 四川农业大学\n",
      "0 >>> #晚安川农# 宁静的 <= 四川农业大学\n",
      "0 >>> #川农夜聊# 大家身 <= 四川农业大学\n",
      "0 >>> #川农微分享#【#四 <= 四川农业大学\n",
      "0 >>> #枣子茶话会# 画画 <= 四川农业大学\n",
      "1 >>> #农场主请你吃安利# <= 青春川农\n",
      "1 >>> ＃农场主听你说＃ <= 青春川农\n",
      "1 >>> #飞花令# <= 青春川农\n",
      "1 >>> #是投稿呀# <= 青春川农\n",
      "0 >>> #农场主听你说# <= 青春川农\n",
      "0 >>> #是投稿呀# <= 青春川农\n",
      "0 >>> #是活动呀# <= 青春川农\n",
      "0 >>> #农场主考考你# <= 青春川农\n",
      "0 >>> ＃早安川农＃ <= 青春川农\n",
      "0 >>> 【关于学生处学生教育 <= 青春川农\n",
      "0 >>> #虽然被封校了，但大 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>>  <= 川农大的某盒子\n",
      "0 >>> #投稿 <= 川农大的某盒子\n",
      "0 >>> #征婚 <= 川农大的某盒子\n",
      "0 >>>  <= 川农大的某盒子\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "0 >>> 【表白墙】 <= 川农大成都校区表白墙\n",
      "1 >>> 图一：找伴 <= 川农大绿帽墙\n",
      "1 >>>  <= 川农大绿帽墙\n",
      "0 >>> 混合贴 <= 川农大绿帽墙\n",
      "0 >>>  <= 川农大绿帽墙\n",
      "0 >>>  <= 川农大绿帽墙\n",
      "0 >>> 今日趣事 <= 川农大绿帽墙\n",
      "0 >>> 混合贴 <= 川农大绿帽墙\n",
      "0 >>> 图一：信科 <= 川农大绿帽墙\n",
      "0 >>> 下午好 <= 川农大绿帽墙\n",
      "0 >>> 混合贴 <= 川农大绿帽墙\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>> 那么新鲜的花 <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "0 >>>  <= 川农大新鲜事\n",
      "1 >>> #投稿合集🦾 <= 川农大表白墙（美好版）\n",
      "1 >>> 【领四六级】 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> 川农也能打9+啦！ <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> 大家有在云养女鹅或者 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集 <= 川农大表白墙（美好版）\n",
      "0 >>> #投稿合集🫰 <= 川农大表白墙（美好版）\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>>  <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "0 >>> 投稿 <= 四川农业大学表白墙\n",
      "1 >>> 图一找对象二维码已换 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 1. [出售] 雅安 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 最美瞬间摄影大赛开始 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>> 我们班50人 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [求助] 拜托 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [征友] 图书 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 在川农大，我们谈场7 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [征友] 扩列 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [找人] 找一 <= 川农大表白墙（舞唱女孩）\n",
      "0 >>> 1. [征友] 找对 <= 川农大表白墙（舞唱女孩）\n",
      "1 >>>  <= 纯路人茉日天\n",
      "1 >>> 全网通知 <= 纯路人茉日天\n",
      "1 >>> 还真是 <= 纯路人茉日天\n",
      "1 >>> 中日文学差异 <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "0 >>>  <= 纯路人茉日天\n",
      "请求发送完毕\n"
     ]
    }
   ],
   "source": [
    "from selenium.webdriver.chrome.options import Options\n",
    "from selenium import webdriver\n",
    "from selenium.webdriver.common.by import By\n",
    "from selenium.webdriver.chrome.service import Service\n",
    "import time\n",
    "import sys\n",
    "import json\n",
    "import qzone\n",
    "\n",
    "# 设置浏览器\n",
    "options = Options()\n",
    "# options.add_argument('blink-settings=imagesEnabled=false')\n",
    "options.add_argument('--window-size=800,400') # 大小\n",
    "options.add_argument('--no-sandbox')\n",
    "options.add_argument('--headless')  # 无头参数浏览器不提供可视化页面\n",
    "options.add_argument('--disable-gpu')\n",
    "options.add_argument('--disable-software-rasterizer')\n",
    "options.add_argument('--disable-extensions')\n",
    "options.add_argument('--ignore-certificate-errors')\n",
    "options.add_argument('--allow-running-insecure-content')\n",
    "\n",
    "driver = webdriver.Chrome(service=Service(r\"./chromedriver\"), options=options)\n",
    "attr = {} # 获取参数\n",
    "with open('./data.json', 'r', encoding='utf8') as fp: attr = json.load(fp)\n",
    "\n",
    "# 开始\n",
    "try:\n",
    "    while True:\n",
    "        qzone.getCode(driver)\n",
    "        time.sleep(30)\n",
    "        print(\"开始访问页面...  \" + time.strftime('%Y-%m-%d %H:%M', time.localtime(time.time())))\n",
    "        lis = qzone.getBlogs(driver,attr)\n",
    "        if (not lis): continue\n",
    "        print(\"页面访问完毕，lis生成，解析发送...\")\n",
    "        qzone.sendBlogs(qzone.handleBlogs(lis))\n",
    "\n",
    "        time.sleep(60*60*6) #秒\n",
    "finally:\n",
    "    driver.quit()\n",
    "    print('浏览器必须退出')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "36266d78-f2e9-427f-be18-fd60c578adb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(lis)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
